package Day8_07_31;

	public class Student {
		   // 属性 Field
		   protected int id; // 1
		   protected String name; // 张三
		   protected int age;// 23
		   protected String className; // Java190703 String类型的默认值是null
		   
		   // 无参构造方法
		   // 如果不写，Java默认提供一个无参构造方法
		   // 如果你写了，Java就不会再提供这个无参的构造方法
		   public Student() {
		     System.out.println("Student.Student()");
		   }
		   
		   // 有参构造方法
		   public Student(int id, String name, int age, String className) {
		     System.out.println("Student.Student() ----");
		     //The assignment to variable id has no effect
		     // id = id;
		     // this代表当前对象
		     this.id = id;
		     this.name = name;
		     this.age = age;
		     this.className = className;
		   }
		   // 方法（功能）Method
		   public void study () {
		     // 局部变量
		     int num = 3;
		     // System.out.println("张三正在Java90703班学习");
		     System.out.println(name + "正在" + className + "班学习");
		   }
		   public int getId() {
		     return id;
		   }
		   public void setId(int id) {
		     this.id = id;
		   }
		   public String getName() {
		     return name;
		   }
		   public void setName(String name) {
		     this.name = name;
		   }
		   public int getAge() {
		     return age;
		   }
		   public void setAge(int age) {
		     // 对非法的年龄进行控制
		     if (age > 0 && age <= 120) {
		        this.age = age;
		     }
		   }
		   public String getClassName() {
		     return className;
		   }
		   public void setClassName(String className) {
		     this.className = className;
		   }
		   @Override
		   public String toString() {
		     // "Student[id=1,name=张三,age=23]"
		     // "Student[id="+id+",name="+name+",age="+age+"]"
		     return "Student [id=" + id + ", name=" + name + ", age=" + age + ", className=" + className + "]";
		   }
	}
